<template>
  <!-- <div class="mainRoom">
    <template v-for="item in goods.tea">
      <div style="width: 80%; margin: 15px auto; box-shadow: 0 0 8px #c3c3c3; padding: 10px; border-radius: 5px;"
        @click="$router.push('detail/' + item.sku)">
        <img :src="item.imgs[0]" alt="">
        <div style="font-size: 18px; color: #ff4949; font-weight: 600">
          <span style="font-size: 12px;">￥</span>{{item.price}}
        </div>
        <div style="font-size: 16px">{{item.name}}</div>
      </div>

    </template>
  </div> -->
  <div id="index" style="background-color:#fff">
    <img src="https://img11.360buyimg.com/cms/jfs/t1/62199/32/6850/573367/5d4eec1dE1ba50aa8/01b26be7808180ba.jpg"
      style="width: 100%;" />

    <div>
      <div style="display: flex; justify-content: space-around">
        <div
          style="font-size: 16px; font-weight: bold; margin: 10px 0; padding: 5px 0; border-bottom: 2px solid #646464">
          精选好茶</div>
      </div>
      <template v-for="item in goods.tea">
        <div style="width: 80%; margin: 15px auto; box-shadow: 0 0 8px #c3c3c3; padding: 10px; border-radius: 5px;"
          @click="detail(item)">
          <!-- <van-image lazy-load :src="item.imgs[0]" style="width: 100%" /> -->
          <img :src="item.imgs[0]" alt="" style="width:100%">
          <div style="font-size: 18px; color: #ff4949; font-weight: 600"><span
              style="font-size: 12px;">￥</span>{{item.price}}</div>
          <div style="font-size: 16px">{{item.name}}</div>
        </div>

      </template>
    </div>



  </div>
</template>

<script>
  import * as ApiService from "api/api";
  import * as Goods from '@/constant/goods'
  import { Dialog, Image } from "vant";
  export default {
    props: {},
    data() {
      return {


        goods: Goods
      };
    },
    components: {
      Dialog,
      // Image
    },
    methods: {
      detail(item) {
        console.log("item= =>", item)
        this.$router.push('/answerP/' + item.sku)
      }

    },
    mounted() {
      console.log("goods==>", Goods)
      // document.cookie = `Authorization=eyJhbGciOiJIUzUxMiJ9.eyJzdWJJZCI6IlNoaUVyIiwic3ViIjoiU2hpRXIiLCJhdWRpZW5jZSI6IndlYiIsImF1dGgiOlsiTEVWRUxfTUFOQUdFUiJdLCJjcmVhdGVkIjoxNTUxNjY2MDcyMjU4LCJleHAiOjE1NTIyNzA4NzJ9.qE9vRAU7dC437HzrMAIEwDnp01lUjoRHDsFYyLll0B_4ubkpvNW7xFdHqw5ZNy9Wxd1N6d8QLLl6G_xtw4VIXQ`;
      // else {
      // ApiService.unit({}).then(res => {
      //   if (res.data.resultDesc == "1") {
      //     if (res.data.rows.length < 2) {
      //       this.overburden = false;
      //       this.prompt = false;
      //       this.unit = res.data.rows[0].cName;
      //       var unitArr = res.data.rows;
      //       var unitObj = {};
      //       for (var key in unitArr) {
      //         unitObj = unitArr[key];
      //       }
      //       localStorage.setItem("unitObj", JSON.stringify(unitObj));
      //     } else {
      //       var coverList = res.data.rows;
      //       if (unitObj) {
      //         for (var i = 0; i < coverList.length; i++) {
      //           if (unitObj.code == coverList[i].code) {
      //             coverList[i].checked = true;
      //             this.unit = coverList[i].cName;
      //           } else {
      //             coverList[i].checked = false;
      //           }
      //         }
      //       } else {
      //         coverList[0].checked = true;
      //         this.coverListIndex = 0;
      //         this.unit = coverList[0].cName;
      //       }
      //       this.coverList = coverList;
      //       this.overburden = true;
      //     }
      //   }
      // });
      // //     }
      // let code = this.getQueryString("code");
      // ApiService.searchUser(code).then(res => {
      //   if (res.data.success) {
      //     // console.log("成功searchUser");
      //     if (res.data.result === "0") {
      //       this.$router.replace({
      //         path: "/login",
      //         query: { id: res.data.userId }
      //       });
      //     } else if (res.data.result === "2") {
      //       Dialog.alert({
      //         message: "当前用户无权限"
      //       }).then(() => {
      //         // on close
      //         window.opener = null;
      //         window.open("", "_self");
      //         window.close();
      //       });
      //     } else {
      //       //  111
      //       var unitObj = JSON.parse(localStorage.getItem("unitObj"));
      //       var arr = [];
      //       if (unitObj) {
      //         ApiService.unit().then(res => {
      //           // console.log("存在缓存", res.data.rows);
      //           // console.log("unitObj", unitObj.code);
      //           let exitBool = res.data.rows.some((item, index) => {
      //             return item.code == unitObj.code;
      //           });
      //           // console.log(exitBool);
      //           // 存在
      //           if (exitBool) {
      //             // console.log("组织单位没变");
      //             this.overburden = false;
      //             this.unit = unitObj.cName;
      //           } else {
      //             ApiService.unit({}).then(res => {
      //               // console.log("unit", res);
      //               if (res.data.resultDesc == "1") {
      //                 if (res.data.rows.length < 2) {
      //                   this.overburden = false;
      //                   this.prompt = false;
      //                   this.unit = res.data.rows[0].cName;
      //                   var unitArr = res.data.rows;
      //                   var unitObj = {};
      //                   for (var key in unitArr) {
      //                     unitObj = unitArr[key];
      //                   }
      //                   localStorage.setItem("unitObj", JSON.stringify(unitObj));
      //                 } else {
      //                   var coverList = res.data.rows;
      //                   if (unitObj) {
      //                     for (var i = 0; i < coverList.length; i++) {
      //                       if (unitObj.code == coverList[i].code) {
      //                         coverList[i].checked = true;
      //                         this.unit = coverList[i].cName;
      //                       } else {
      //                         coverList[i].checked = false;
      //                       }
      //                     }
      //                   } else {
      //                     coverList[0].checked = true;
      //                     this.coverListIndex = 0;
      //                     this.unit = coverList[0].cName;
      //                   }
      //                   this.coverList = coverList;
      //                   this.overburden = true;
      //                 }
      //               }
      //             });
      //           }
      //         });
      //       }
      //     }
      //   }
      // });
    }
  };
</script>

<style scoped lang="less" rel="stylesheet/less">
  .mainRoom {
    .unit {
      position: relative;
      text-align: center;
      padding: 4vw 2vw;
      color: #fff;
      background-color: #4e76a9;

      .qh {
        display: block;
        position: absolute;
        right: 0;
        padding: 4vw;
        line-height: 4vw;
        bottom: 0;
        font-size: 14px;
      }
    }

    position: relative;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;

    .list {
      display: flex;

      .list_item {
        width: 50%;
        border: 1px solid #eee;
        text-align: center;
        padding: 6vw 0;
        background-color: #fff;

        img {
          display: block;
          width: 17vw;
          margin: 3vw auto;
        }
      }
    }

    .prompt {
      position: fixed;
      top: 30vh;
      left: 15%;
      height: 18vh;
      width: 70%;
      text-align: center;
      line-height: 18vh;
      font-size: 1.5rem;
      letter-spacing: 0.1rem;
      border-radius: 4px;
      color: #fff;
      background-color: rgba(0, 0, 0, 0.4);
    }

    .cover {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background-color: rgba(0, 0, 0, 0.4);

      .content {
        width: 80%;
        height: 60vh;
        background-color: #fff;
        position: absolute;
        left: 10%;
        top: 20vh;
        overflow: hidden;
        -webkit-transition: all 0.3s ease;
        -moz-transition: all 0.3s ease;
        -o-transition: all 0.3s ease;
        transition: all 0.3s ease;

        p {
          text-align: center;
          height: 8vh;
          line-height: 8vh;
          font-size: 1.3rem;
          background-color: #eee;
          letter-spacing: 0.1rem;
        }

        ul {
          height: 44vh;
          overflow-x: hidden;
          overflow: scroll;

          li {
            padding: 5%;

            label {
              height: 5vh;
              line-height: 5vh;
              display: block;

              input {
                -web-kit-appearance: none;
                -moz-appearance: none;
                font-size: 1.4em;
                height: 1em;
                border-radius: 4px;
                border: 1px solid #c8cccf;
                color: #6a6f77;
                outline: 0;
                float: right;
                width: 1em;
                text-align: right;
              }

              .input_control {
                width: 360px;
                margin: 20px auto;
              }

              input[type="text"],
              #btn1,
              #btn2 {
                box-sizing: border-box;
                text-align: center;
                font-size: 1.4em;
                height: 1em;
                border-radius: 4px;
                border: 1px solid #c8cccf;
                color: #6a6f77;
                -web-kit-appearance: none;
                -moz-appearance: none;
                display: block;
                outline: 0;
                padding: 0 1em;
                text-decoration: none;
                width: 100%;
              }

              input[type="text"]:focus {
                border: 1px solid #ff7496;
              }
            }
          }
        }

        .instruct {
          display: flex;
          justify-content: space-between;
          height: 8vh;
          line-height: 8vh;
          font-size: 1.3rem;
          letter-spacing: 0.1rem;

          p {
            width: 49.9%;
            color: #00bf60;
          }

          p:first-child {
            color: #f99b46;
          }
        }
      }
    }
  }
</style>